home *** CD-ROM | disk | FTP | other *** search
/ Aminet 15 / Aminet 15 - Nov 1996.iso / Aminet / dev / basic / ace24dist.lha / ace24.lha / include / ace / strings.h < prev   
Text File  |  1996-09-10  |  2KB  |  76 lines

  1. /* From XRACTON@FULLERTON.EDU Thu Jun 24 00:39:17 1993 */
  2.  
  3. Rem *** LCASE$ (function)
  4. Rem ***
  5. Rem *** FUNCTION:
  6. Rem *** Simulates the LCASE$ function hard-wired into some other
  7. Rem *** BASICs. Takes a string as input, and returns that string
  8. Rem *** with all uppercase letters converted to lowercase.
  9. Rem ***
  10. Rem *** REVISION HISTORY:
  11. Rem *** Version 1.0: Roland Acton (xracton@ccvax.fullerton.edu)
  12. Rem ***
  13. Rem *** BUGS:
  14. Rem *** Can only handle strings up to MAXSTRINGLEN.
  15.  
  16. SUB LCASE$(A$)
  17.   Longint STEPPER
  18.   String B$
  19.   B$=A$
  20.   STEPPER=@B$
  21. Rem *** Not perfectly portable, but everybody uses ASCII these days,
  22. Rem *** right?
  23.   Repeat
  24.     If Peek(STEPPER)>=65 And Peek(STEPPER)<=90 Then
  25.       Poke STEPPER,Peek(STEPPER)+32
  26.     End If
  27.     ++STEPPER
  28.   Until Peek(STEPPER)=0
  29.   LCASE$=B$
  30. END SUB
  31.  
  32.  
  33.  
  34. Rem *** MIDCOM$ (function)
  35. Rem ***
  36. Rem *** FUNCTION:
  37. Rem *** Simulates the MID$ command. A$, starting at position B%, has
  38. Rem *** its contents replaced by C$. This is done until either D%
  39. Rem *** characters have been replaced, or the end of either A$ or C$
  40. Rem *** has been reached. This is consistent with the way it is
  41. Rem *** implemented in AmigaBASIC (though AmigaBASIC uses a
  42. Rem *** different syntax). The contents of A$ are then returned to
  43. Rem *** the calling program.
  44. Rem *** For example, if NAME$ contains the string "Goodbye",
  45. Rem ***
  46. Rem *** NAGISA$=MIDCOM$(NAME$,2,"Iczer",1)
  47. Rem ***
  48. Rem *** will make NAGISA$ contain the string "GIodbye". NAME$ will
  49. Rem *** be unaffected. Thus, if you actually wanted to alter NAME$
  50. Rem *** (as the "real" MID$ command would do) you would have to use
  51. Rem ***
  52. Rem *** NAME$=MIDCOM$(NAME$,2,"Iczer",1)
  53. Rem ***
  54. Rem *** Note that since ACE does not allow function overloading, all
  55. Rem *** four parameters are required. Pass D% a very high number if
  56. Rem *** you want it ignored.
  57. Rem ***
  58. Rem *** REVISION HISTORY:
  59. Rem *** Version 1.0: Roland Acton (xracton@ccvax.fullerton.edu)
  60. Rem ***
  61. Rem *** BUGS:
  62. Rem *** None known.
  63.  
  64. SUB MIDCOM$(A$,B%,C$,D%)
  65.   Longint STEPA, STEPC
  66.   STEPA=@A$+B%-1
  67.   STEPC=@C$
  68.   While Peek(STEPA)<>0 And Peek(STEPC)<>0 And D%>0
  69.     Poke STEPA,Peek(STEPC)
  70.     ++STEPA
  71.     ++STEPC
  72.     --D%
  73.   Wend
  74.   MIDCOM$=A$
  75. END SUB
  76.